<CFPARAM NAME="lPreProcessShowMsg" DEFAULT="NO">
<CFIF lPreProcessShowMsg EQ "Yes">
<table border=0 cellpadding="1px" cellspacing=0 width="100%">
</CFIF>
<CFQUERY NAME="qryCLKLVCODE" DATASOURCE=#client.company_dsn#>
	SELECT WITHBALANCE, ALLOWNEGBALANCE
	FROM CLKLVCODE
	WHERE LEAVETYPE = '#Evaluate("GETENTRY.LEAVETYPE")#'

</CFQUERY>
<CFQUERY NAME="qryCINWSMASTER" DATASOURCE=#client.company_dsn#>
	SELECT A.PERSONNELIDNO, A.WORKSKEDCODE, A.STARTDATE, B.MONDAY, B.TUESDAY, B.WEDNESDAY, B.THURSDAY, B.FRIDAY, B.SATURDAY, B.SUNDAY
	FROM CINWSMASTER A, CLKWORKSKED B
	WHERE (A.PERSONNELIDNO = '#GETENTRY.PERSONNELIDNO#'<!---<CFIF GETENTRY.STAFFPID NEQ "">'#GETENTRY.STAFFPID#'<CFELSE>'#GETENTRY.PERSONNELIDNO#'</CFIF>--->) 
	AND (A.ACTIVESKED = 'Y') AND (A.STARTDATE =
		(SELECT MAX(STARTDATE) AS STARTDATE
		FROM CINWSMASTER
		WHERE (PERSONNELIDNO = '#GETENTRY.PERSONNELIDNO#'<!---<CFIF GETENTRY.STAFFPID NEQ "">'#GETENTRY.STAFFPID#'<CFELSE>'#GETENTRY.PERSONNELIDNO#'</CFIF>--->) AND (ACTIVESKED = 'Y')))
		AND A.WORKSKEDCODE = B.WORKSKEDCODE
</CFQUERY>
<CFSET WITHAPPSD=FALSE>
<CFSET nDeductedDay = 0>
<CFSET theDate= #DATEFORMAT(GETENTRY.STARTINGDATE, "mm/dd/yyyy")#>
<CFSET lastValidDate = theDate>
<CFSET sNoofDays= DateDiff("d", "#GETENTRY.STARTINGDATE#", "#GETENTRY.ENDINGDATE#") + 1>
<CFSET theRefDate="">
<CFOUTPUT QUERY="GETENTRY">
	<CFLOOP index="noofdays" FROM="1" TO="#sNoofDays#" STEP="1">
		<CFSET ValidateDate=DayOfWeekAsString(DayOfWeek("#theDate#"))>
		<!--- Modified by Maan 05112007... working day may fall on sunday or saturday --->
		<!---<CFIF ValidateDate NEQ "Sunday">
			<CFIF ValidateDate NEQ "Saturday">--->
				
				<!---Modified by Gene as of 07/27/12--->
					<CFIF isDefined("GetEntry.STAFFPID")>
						<CFIF GetEntry.STAFFPID NEQ "">
						<CFSET formPID = GetEntry.STAFFPID>
						<CFELSE>
						<CFSET formPID = GetEntry.PERSONNELIDNO>
						</CFIF>
					<CFELSE>
					<CFSET formPID = GetEntry.PERSONNELIDNO>
					</CFIF>
				
				<CFIF GETENTRY.STAFFPID NEQ "">
					<!---Modified by Gene as of 07/27/12--->
					<CFQUERY NAME="qryLEAVEAPPSD" DATASOURCE="#client.company_dsn#">
						SELECT REFERENCEDATE
						FROM CINLEAVEAPPSD
						WHERE PERSONNELIDNO = '#GETENTRY.STAFFPID#' AND REFERENCEDATE = '#theDate#' AND LEAVETYPE='#GETENTRY.LEAVETYPE#'
					</CFQUERY>
				<CFELSE>
					<CFQUERY NAME="qryLEAVEAPPSD" DATASOURCE="#client.company_dsn#">
						SELECT REFERENCEDATE
						FROM CINLEAVEAPPSD
						WHERE PERSONNELIDNO = '#GETENTRY.PERSONNELIDNO#' AND REFERENCEDATE = '#theDate#' AND LEAVETYPE='#GETENTRY.LEAVETYPE#'
					</CFQUERY>
				</CFIF>
				<CFIF qryLEAVEAPPSD.RECORDCOUNT>
					<CFSET WITHAPPSD=TRUE>
					<CFBREAK>
				</CFIF>
			<!---</CFIF>
		</CFIF>--->
		<CFSET ValidateDate="">
		<CFSET theDate= DATEFORMAT(DateAdd("D",1, "#theDate#"))>
	</CFLOOP>
</CFOUTPUT>
<CFIF NOT qryCLKLVCODE.RecordCount><!--- Check CLKLVCODE for Leave Type --->
	<CFIF lPreProcessShowMsg EQ "Yes">
	<tr><td nowrap class="bold">Leave Type not found in Lookup table.</td></tr>
	</CFIF>
<CFELSEIF NOT qryCINWSMASTER.RecordCount> <!--- Check CINWSMASTER for Work Sked --->
	<CFIF lPreProcessShowMsg EQ "Yes">
	<tr><td nowrap class="bold">Employee Worksked not properly set-up.</td></tr>
	</CFIF>
<CFELSEIF qryCINWSMASTER.STARTDATE GT DateFormat(Now(),"mm/dd/yyyy")> <!--- Check CINWSMASTER Start Date Effectivity --->
	<CFIF lPreProcessShowMsg EQ "Yes">
	<tr><td nowrap class="bold">No configured Permanent WorkSked. Please contact your iBOS/e Administrator.</td></tr>
	</CFIF>
<CFELSEIF WITHAPPSD> <!--- Check if leave date was availed --->
	<CFIF lPreProcessShowMsg EQ "Yes">
	<tr><td nowrap class="bold"><CFOUTPUT>Leave with date #DATEFORMAT(qryLEAVEAPPSD.REFERENCEDATE,"mmmm dd,yyyy")# has already been availed.</CFOUTPUT></td></tr>
	</CFIF>
<CFELSEIF Trim(Ucase(qryCLKLVCODE.WITHBALANCE)) IS "N">
	<CFIF lPreProcessShowMsg EQ "Yes">
	<tr><td nowrap class="bold">Leave Type has unlimited balance.</td></tr>
	</CFIF>
	<CFSET lPreProcessValidated="Yes">
<CFELSE>
	<CFIF isDefined("GetEntry.STAFFPID")>
		<CFIF GetEntry.STAFFPID NEQ "">
			<CFSET formPID = GetEntry.STAFFPID>
		<CFELSE>
			<CFSET formPID = GetEntry.PERSONNELIDNO>
		</CFIF>
	<CFELSE>
		<CFSET formPID = GetEntry.PERSONNELIDNO>
	</CFIF>
	<CFQUERY NAME="qryCINLVENTITLEMENT" DATASOURCE="#client.company_dsn#">
		SELECT LEAVEENTITLEMENT, TYPE, STARTDATE, ACCRUEDBALANCE, ACCRUEDBALANCEASOF,
				LEAVEBALANCE, LEAVEBALANCEASOF, AVAILEDLEAVE, AVAILEDLEAVEASOF, LEAVETYPE
		FROM CINLVENTITLEMENT
		WHERE PERSONNELIDNO = '#formPID#' AND
			LEAVETYPE = '#Evaluate("GetEntry.LEAVETYPE")#'
	</CFQUERY>

	<CFIF qryCINLVENTITLEMENT.RecordCount>
		<CFQUERY NAME="qryCBR201" DATASOURCE=#client.company_dsn# MAXROWS=1>
			SELECT LEAVETRACKUNIT
			FROM CBR201
		</CFQUERY>

		<CFIF qryCBR201.RecordCount>
			<!--- Check workingdayscode --->
			<CFSET deductedDate = "">
			<CFQUERY NAME="qryCMFPA" DATASOURCE="#client.company_dsn#">
				SELECT *
				FROM CMFPA
				WHERE PERSONNELIDNO = '#formPID#'
			</CFQUERY>

			<CFQUERY NAME="qryCLKWORKINGDAYS" DATASOURCE="#client.company_dsn#">
				SELECT WORKINGHOURSPDAY,WORKINGHOURSFORLV
				FROM CLKWORKINGDAYS
				WHERE WORKINGDAYSCODE = '#qryCMFPA.WORKINGDAYSCODE#'
			</CFQUERY>
			<CFSET theDate= #DATEFORMAT(GETENTRY.STARTINGDATE, "mm/dd/yyyy")#>
			<CFIF qryCLKWORKINGDAYS.RecordCount>
				<CFSET sWithTempSked = "">
				<CFSET sWithSubSked = "">
				<CFSET dSubSked = "">
				<!--- by Maan 05102007 deduct holidays and rest day/day off--->
				<CFQUERY NAME="qryCINWSSUBSKED" DATASOURCE="#client.company_dsn#">
					SELECT A.REFERENCEDATE, A.PERSONNELIDNO, A.PATTERNCODE
					FROM CINWSSUBSKED A, CLKWSPATTERN B
					WHERE A.PATTERNCODE = B.PATTERNCODE AND A.PERSONNELIDNO = '#formPID#' AND  B.DAYTYPE IN ('DO','RD')
				</CFQUERY>
				<CFIF qryCINWSSUBSKED.RECORDCOUNT NEQ 0>
					<CFLOOP QUERY="qryCINWSSUBSKED">
						<CFSET dSubSked = ListAppend(dSubSked,DateFormat(REFERENCEDATE,"mm/dd/yyyy"))>
					</CFLOOP>
				</CFIF>
				<!--- pre process tempsked --->
				<CFQUERY NAME="qryCINWSTEMPSKED" DATASOURCE="#client.company_dsn#">
					SELECT A.PERSONNELIDNO, A.WORKSKEDCODE, A.STARTDATE, A.ENDDATE, B.MONDAY, B.TUESDAY, B.WEDNESDAY, B.THURSDAY, B.FRIDAY, B.SATURDAY, B.SUNDAY
					FROM CINWSTEMPSKED A, CLKWORKSKED B
					WHERE (PERSONNELIDNO = '#formPID#') AND (A.ENDDATE =
						(SELECT MAX(ENDDATE) AS ENDDATE
						FROM CINWSTEMPSKED
						WHERE PERSONNELIDNO = '#formPID#')) AND A.WORKSKEDCODE = B.WORKSKEDCODE
				</CFQUERY>
				<CFQUERY NAME="qryCLKWSHOLIDAYS" DATASOURCE="#client.company_dsn#">
					SELECT HOLIDAYMONTH,HOLIDAYDAY,HALF_DAY
					FROM CLKWSHOLIDAYS
				</CFQUERY>
				
				<CFSET theDate= #DATEFORMAT(GETENTRY.STARTINGDATE, "mm/dd/yyyy")#>
				<CFSET sNoofDays= DateDiff("d", "#GETENTRY.STARTINGDATE#", "#GETENTRY.ENDINGDATE#") + 1>
				<CFSET theRefDate="">
				<CFSET holidaycount="">
				<cfset dates = "">
				<!--- start the validation, process date by date --->
				<CFLOOP index="holidaycount" FROM="1" TO="#sNoofDays#" STEP="1">
					<CFSET nDay = DayOfWeek(theDate)>
					<CFSET nNonHolidayMonth=DateFormat("#theDate#","m")>
					<CFSET nNonHolidayDay=DateFormat("#theDate#","d")>
					<CFSET isHoliday = "No">
					<CFSET stheDay = "">
					
					<!--- subsked first--->
					<CFIF ListFind(dSubSked,DateFormat(theDate,"mm/dd/yyyy")) NEQ "0">
					<cfset session.11wats = "subsked">
						<CFSET subRefDate = ListGetAt(dSubSked, ListFind(dSubSked,DateFormat(theDate,"mm/dd/yyyy")))>
						<!--- this rd/do by subsked must not be a holiday --->	
						<CFLOOP QUERY="qryCLKWSHOLIDAYS">
							<CFIF HOLIDAYMONTH EQ nNonHolidayMonth AND HOLIDAYDAY EQ nNonHolidayDay>
								<!--- it is a holiday! --->
								<CFSET nDeductedDay=nDeductedDay + 1>
								<CFSET isHoliday = "Yes">
								<cfset dates = ListAppend(dates,DateFormat(theDate,"mm/dd/yyyy"))>
							</CFIF>
						</CFLOOP>
						<CFIF isHoliday EQ "No">
							<CFSET nDeductedDay=nDeductedDay + 1>
							<cfset dates = ListAppend(dates,DateFormat(theDate,"mm/dd/yyyy"))>
						</CFIF>
					<CFELSEIF qryCINWSTEMPSKED.ENDDATE GTE theDate AND theDate NEQ qryCINWSSUBSKED.REFERENCEDATE>
					<!--- if not subsked, tempsked next --->
					<cfset session.11watt = "tempsked">
						<CFIF qryCINWSTEMPSKED.STARTDATE LTE getEntry.STARTINGDATE>
							<CFIF qryCINWSTEMPSKED.MONDAY    EQ "RD" OR qryCINWSTEMPSKED.MONDAY    EQ "DO"><CFSET stheDay = ListAppend(stheDay,"2")></CFIF>
							<CFIF qryCINWSTEMPSKED.TUESDAY   EQ "RD" OR qryCINWSTEMPSKED.TUESDAY   EQ "DO"><CFSET stheDay = ListAppend(stheDay,"3")></CFIF>
							<CFIF qryCINWSTEMPSKED.WEDNESDAY EQ "RD" OR qryCINWSTEMPSKED.WEDNESDAY EQ "DO"><CFSET stheDay = ListAppend(stheDay,"4")></CFIF>
							<CFIF qryCINWSTEMPSKED.THURSDAY  EQ "RD" OR qryCINWSTEMPSKED.THURSDAY  EQ "DO"><CFSET stheDay = ListAppend(stheDay,"5")></CFIF>
							<CFIF qryCINWSTEMPSKED.FRIDAY    EQ "RD" OR qryCINWSTEMPSKED.FRIDAY    EQ "DO"><CFSET stheDay = ListAppend(stheDay,"6")></CFIF>
							<CFIF qryCINWSTEMPSKED.SATURDAY  EQ "RD" OR qryCINWSTEMPSKED.SATURDAY  EQ "DO"><CFSET stheDay = ListAppend(stheDay,"7")></CFIF>
							<CFIF qryCINWSTEMPSKED.SUNDAY    EQ "RD" OR qryCINWSTEMPSKED.SUNDAY    EQ "DO"><CFSET stheDay = ListAppend(stheDay,"1")></CFIF>
						</CFIF>
						<CFLOOP LIST="#stheDay#" INDEX="noWork">
							<CFIF nDay EQ noWork>
								<CFSET nDeductedDay=nDeductedDay + 1>
								<cfset dates = ListAppend(dates,DateFormat(theDate,"mm/dd/yyyy"))>
								
							</CFIF>
						</CFLOOP>
						<!--- deduct holidays that are not rest day / day off--->
						<CFIF listFindNoCase(stheDay,nDay) NEQ "0">
							<CFLOOP QUERY="qryCLKWSHOLIDAYS">
								<CFIF HOLIDAYMONTH EQ nNonHolidayMonth AND HOLIDAYDAY EQ nNonHolidayDay>
									<!--- count every holiday in leave range --->
									<CFSET nDeductedDay=nDeductedDay + 1>
									<cfset dates = ListAppend(dates,DateFormat(theDate,"mm/dd/yyyy"))>
								</CFIF>
							</CFLOOP>
						</CFIF>
					<CFELSE>
					<!--- permanent sked --->
					<cfset session.11watp = "permanent">
						<CFIF qryCINWSMASTER.STARTDATE LTE getEntry.STARTINGDATE>
							<CFIF qryCINWSMASTER.MONDAY    EQ "RD" OR qryCINWSMASTER.MONDAY    EQ "DO"><CFSET stheDay ="2"></CFIF>
							<CFIF qryCINWSMASTER.TUESDAY   EQ "RD" OR qryCINWSMASTER.TUESDAY   EQ "DO"><CFSET stheDay = ListAppend(stheDay,"3")></CFIF>
							<CFIF qryCINWSMASTER.WEDNESDAY EQ "RD" OR qryCINWSMASTER.WEDNESDAY EQ "DO"><CFSET stheDay = ListAppend(stheDay,"4")></CFIF>
							<CFIF qryCINWSMASTER.THURSDAY  EQ "RD" OR qryCINWSMASTER.THURSDAY  EQ "DO"><CFSET stheDay = ListAppend(stheDay,"5")></CFIF>
							<CFIF qryCINWSMASTER.FRIDAY    EQ "RD" OR qryCINWSMASTER.FRIDAY    EQ "DO"><CFSET stheDay = ListAppend(stheDay,"6")></CFIF>
							<CFIF qryCINWSMASTER.SATURDAY  EQ "RD" OR qryCINWSMASTER.SATURDAY  EQ "DO"><CFSET stheDay = ListAppend(stheDay,"7")></CFIF>
							<CFIF qryCINWSMASTER.SUNDAY    EQ "RD" OR qryCINWSMASTER.SUNDAY    EQ "DO"><CFSET stheDay = ListAppend(stheDay,"1")></CFIF>
						</CFIF>
						<CFLOOP LIST="#stheDay#" INDEX="noWork">
							<CFIF nDay EQ noWork>
								<CFSET nDeductedDay=nDeductedDay + 1>
								<cfset dates = ListAppend(dates,DateFormat(theDate,"mm/dd/yyyy"))>
							</CFIF>
						</CFLOOP>
						<!--- deduct holidays that are not rest day / day off--->
						<!--- stheDay is the RD, DO; nDay is the currently processed day --->
						<CFIF listFindNoCase(stheDay,nDay) EQ "0">
							<CFLOOP QUERY="qryCLKWSHOLIDAYS">
								<CFIF HOLIDAYMONTH EQ nNonHolidayMonth AND HOLIDAYDAY EQ nNonHolidayDay>
									<!--- count every holiday in leave range --->
									<CFSET nDeductedDay=nDeductedDay + 1>
									<cfset dates = ListAppend(dates,DateFormat(theDate,"mm/dd/yyyy"))>
								</CFIF>
							</CFLOOP>
						</CFIF>
					</CFIF>
					<CFSET theDate= DATEFORMAT(DateAdd("D",1, "#theDate#"))>
				</CFLOOP>
				<cfset session.111mydate = dates>
				<!--- end of work sked/holiday validation --->
				
				<!--- the NOOFDAYS (START TO END DATE) less of holiday dates--->
				<CFSET nTotalLVDays = sNoofDays - nDeductedDay>
				<cfset session.11noofdays=sNoofDays>
				<cfset session.11nDeductedDay=nDeductedDay>
				<cfset session.11nTotalLVDays=nTotalLVDays>
				<!--- Check if noofhours exceed noofdays 
				<CFSET nHoursInDays=DateDiff("d", Evaluate("GetEntry.STARTINGDATE"), Evaluate("GetEntry.ENDINGDATE")) + 1>--->
<!---				modified by soti to be in sync with updateLVBalance.cfm
				<CFSET nHoursApplied=Evaluate("GetEntry.LEAVEHOURS")>

				<CFIF IsDefined("GetEntry.NOOFDAYS") AND Trim(LCase(qryCBR201.LEAVETRACKUNIT)) EQ "by day">
					<CFSET nHoursApplied=Evaluate("GetEntry.NOOFDAYS")>
				</CFIF> --->
				
				<!--- check if leave will be counted as per hour or per day--->
				<CFIF Trim(LCase(qryCBR201.LEAVETRACKUNIT)) IS "by day">
					<CFSET nHoursApplied = (val(GetEntry.NOOFDAYS) * (val(qryCLKWORKINGDAYS.WORKINGHOURSFORLV) / val(qryCLKWORKINGDAYS.WORKINGHOURSPDAY))) + (val(GetEntry.LEAVEHOURS) / val(qryCLKWORKINGDAYS.WORKINGHOURSFORLV))>
				<CFELSE>
					<CFSET nHoursApplied = (val(GetEntry.NOOFDAYS) * val(qryCLKWORKINGDAYS.WORKINGHOURSFORLV)) + val(GetEntry.LEAVEHOURS)>
				</CFIF>
<!---
				<CFIF nHoursInDays GTE 0>
					<CFSET nHoursInDays=nHoursInDays + 1>
				</CFIF>
--->	
				<CFIF nHoursApplied NEQ "" AND nHoursApplied NEQ 0>
					<CFIF Trim(LCase(qryCBR201.LEAVETRACKUNIT)) NEQ "by day">
						<!--- get number of hours of days--->
						<CFSET nHoursInDays=nTotalLVDays * qryCLKWORKINGDAYS.WORKINGHOURSPDAY>
					<CFELSE>
						<CFSET nHoursInDays=nTotalLVDays>
					</CFIF>

					<CFIF nHoursApplied LTE nHoursInDays>
						<!--- should not be equal or greater than 1 --->
						<CFIF nHoursInDays - nHoursApplied LT 1 >
							<CFSET nLVHours=val(qryCINLVENTITLEMENT.LEAVEBALANCE)>
	
							<CFIF LCase(#GetEntry.WITHPAY#) EQ "Y">
								<CFSET nLVBalance=nLVHours - nHoursApplied>
							<CFELSE>
								<CFSET nLVBalance=nLVHours>
							</CFIF>
	
							<CFOUTPUT>
							<CFIF lPreProcessShowMsg EQ "Yes">
							<tr>
								<!---by jepoy--->
								<td width="25%">
									<table border=0 cellpadding=2 cellspacing=0 width="100%">
									<tr>
										<td nowrap>Personnel ID No.&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCMFPA.PERSONNELIDNO#</td>
									</tr>
									<tr>
										<td nowrap>Last Name&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCMFPA.LASTNAME#</td>
									</tr>
									<tr>
										<td nowrap>First Name&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCMFPA.FIRSTNAME#</td>
									</tr>
									</table>
								</td>
								<td bgcolor="##808080"></td>
								<!---by jepoy END HERE--->
								<td width="25%">
									<table border=0 cellpadding=2 cellspacing=0 width="100%">
									<tr>
										<td nowrap>Leave Type&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCINLVENTITLEMENT.LEAVETYPE#</td>
									</tr>
									<tr>
										<td nowrap>Leave Balance as of cut-off&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCINLVENTITLEMENT.LEAVEBALANCE#</td>
									</tr>
									<tr>
										<td nowrap>Leave Balance as of&nbsp;</td>
										<td nowrap width="100%" class="bold">#DateFormat(qryCINLVENTITLEMENT.LEAVEBALANCEASOF, "mm/dd/yyyy")#</td>
									</tr>
									</table>
								</td>
								<td bgcolor="##808080"></td>
								<td width="25%">
									<table border=0 cellpadding=2 cellspacing=0 width="100%">
									<tr>
										<td nowrap>&nbsp;Type&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCINLVENTITLEMENT.TYPE#</td>
									</tr>
									<tr>
										<td nowrap>&nbsp;Entitlement&nbsp;</td>
										<td nowrap width="100%" class="bold">#qryCINLVENTITLEMENT.LEAVEENTITLEMENT#</td>
									</tr>
									<tr>
										<td nowrap>&nbsp;Start Date&nbsp;</td>
										<td nowrap width="100%" class="bold">#DateFormat(qryCINLVENTITLEMENT.STARTDATE, "mm/dd/yyyy")#</td>
									</tr>
									</table>
								</td>
								<td bgcolor="##808080"></td>
								<td width="25%">
									<table border=0 cellpadding=2 cellspacing=0 width="100%">
									<CFIF UCase(qryCINLVENTITLEMENT.TYPE) IS "EARNED">
										<tr>
											<td nowrap>&nbsp;Availed Leave&nbsp;</td>
											<td nowrap width="100%" class="bold">#qryCINLVENTITLEMENT.AVAILEDLEAVE#</td>
										</tr>
										<tr>
											<td nowrap>&nbsp;Availed Leave as of&nbsp;</td>
											<td nowrap width="100%" class="bold">#DateFormat(qryCINLVENTITLEMENT.AVAILEDLEAVEASOF, "mm/dd/yyyy")#</td>
										</tr>
									<CFELSE>
										<tr>
											<td nowrap>&nbsp;Accrued Balance&nbsp;</td>
											<td nowrap width="100%" class="bold">#qryCINLVENTITLEMENT.ACCRUEDBALANCE#</td>
										</tr>
										<tr>
											<td nowrap>&nbsp;Accrued Balance as of&nbsp;</td>
											<td nowrap width="100%" class="bold">#DateFormat(qryCINLVENTITLEMENT.ACCRUEDBALANCEASOF, "mm/dd/yyyy")#</td>
										</tr>
									</CFIF>
									<CFIF UCase(Evaluate("GetEntry.APPROVED")) NEQ "Y" OR UCase(Evaluate("GetEntry.APPROVED")) NEQ "C">
										<tr>
											<td nowrap>&nbsp;Leave Balance if Approved&nbsp;</td>
											<td nowrap width="100%" class="bold">
												#nLVBalance#
												<CFIF nLVBalance LT 0 AND qryCLKLVCODE.ALLOWNEGBALANCE NEQ "Y">
													(Negative Balance is not allowed)	
													<script type="text/javascript">
														alert("Negative Balance is not allowed")
													</script>
												</CFIF>
												<CFIF LCase(#GetEntry.WITHPAY#) NEQ "Y">
													(Leave Application is without pay)
													<script type="text/javascript">
														alert("Leave Application is without pay")
													</script>
												</CFIF>
											</td>
										</tr>
									</CFIF>
									</table>
								</td>
							</tr>
							
							</CFIF><!--- lPreProcessShowMsg --->
							<!--- Check if employee has enough leave balance --->
							<CFIF (nLVBalance GE 0) OR
								  (qryCLKLVCODE.ALLOWNEGBALANCE IS "Y")>
								<CFSET lPreProcessValidated="Yes">
							</CFIF>
							</CFOUTPUT>
						<CFELSE>
							<CFIF lPreProcessShowMsg EQ "Yes">
								<tr><td nowrap class="bold">No. of days/hours applied exceeds No. of days.</td></tr>
							</CFIF>
					</CFIF><!--- nHoursInDays - nHoursApplied LT 1 --->
					<CFELSE>
						<CFIF lPreProcessShowMsg EQ "Yes">
						<tr><td nowrap class="bold">No. of days/hours applied exceeds No. of days.</td></tr>
						</CFIF>
					</CFIF><!--- nHoursApplied LTE nHoursInDays --->
				<CFELSE>
					<CFIF lPreProcessShowMsg EQ "Yes">
					<tr><td nowrap class="bold">No. of days/hours applied is 0.</td></tr>
					</CFIF>
				</CFIF><!--- nHoursApplied NEQ "" AND nHoursApplied NEQ 0 --->
			<CFELSE>
				<CFIF lPreProcessShowMsg EQ "Yes">
				<tr><td nowrap class="bold">Invalid WORKINGDAYSCODE.</td></tr>
				</CFIF>
			</CFIF><!--- qryCLKWORKINGDAYS.RecordCount --->
		<CFELSE>
			<CFIF lPreProcessShowMsg EQ "Yes">
			<tr><td nowrap class="bold">Leave Track Unit is not properly configured.</td></tr>
			</CFIF>
		</CFIF><!--- qryCBR201.RecordCount --->
	<CFELSE>
		<CFIF lPreProcessShowMsg EQ "Yes">
		<tr><td nowrap class="bold">Leave Type is not yet defined.  Please contact your system administrator.</td></tr>
		</CFIF>
	</CFIF><!--- qryCINLVENTITLEMENT.RECORDCOUNT --->
</CFIF>
<CFIF lPreProcessShowMsg EQ "Yes">
</table>
</CFIF>
